package cn.hy.dataSync.controller;

import cn.hy.dataSync.config.JobConfig;
import cn.hy.dataSync.service.MigrateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Future;

@RestController
@RequestMapping("/")
public class DataSyncController {

    @Autowired
    private MigrateService migrateService;

    @PostMapping("/data/sync")
    public Object sync(@RequestBody JobConfig jobConfig) throws Exception {
        Future<?> future = migrateService.submitAsync(jobConfig);
        return future.get();
    }
}
